package com.platform.controller.backend;

import com.github.pagehelper.PageInfo;
import com.platform.base.BaseController;
import com.platform.common.Const;
import com.platform.common.ServerResponse;
import com.platform.pojo.Permission;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 操作权限
 */
@RestController
@RequestMapping(value = "/permissionController/")
@CrossOrigin(origins = Const.REQUESTURL,maxAge = 3600,allowCredentials = "true")
public class PermissionController extends BaseController {



    @PostMapping(value = "add.do")
    public ServerResponse<String> addPermission(@RequestParam Map paramMap){
        return iPermissionService.insert(paramMap);
    }

    @PostMapping(value = "del.do")
    public ServerResponse<String> delPermission(int id){
        return iPermissionService.del(id);
    }

    @PostMapping(value = "update.do")
    public ServerResponse<Permission> updatePermission(@RequestParam Map paramMap){
        return iPermissionService.update(paramMap);
    }

    @GetMapping(value = "selectByRoleCode.do")
    public ServerResponse<PageInfo> selectByRoleCode(@RequestParam Map paramMap){

        return iPermissionService.selectByRoleCode(paramMap);

    }

    /**
     * 列表页查询
     * @param param
     * @return
     */
    @GetMapping(value = "selectByParam.do")
    public ServerResponse<PageInfo> selectByParam(@RequestParam Map param, HttpServletRequest request){
        return iPermissionService.selectByParam(param);
    }

}
